home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-101.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  46.2 KB  |  1,178 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Sun, 31 May 92       Volume 1 : Issue 101
  2.  
  3. Today's Topics:
  4.  
  5.     WANTED: Good/Comprehensive Mac Programming Book
  6.     Format of ICON resource
  7.     Numerical Programming in Think C
  8.     Hey! I wrote a book!
  9.     Introduction To Video Colour Spaces (was Re: YUV format)
  10.  
  11.  
  12. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  13.  
  14. These digests are available (by using FTP, account anonymous, your email
  15. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  16. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  17. Questions list.  The last several issues of the digest are available from
  18. sumex-aim.stanford.edu as well.
  19.  
  20. These digests are also available via email.  Just send a note saying that you
  21. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  22. automatically receive each new digest as it is created.
  23.  
  24. The digest is a collection of articles from the internet newsgroup comp.sys.
  25. mac.programmer.  It is designed for people who read c.s.m.p. semi-regularly
  26. and want an archive of the discussions.  If you don't know what a newsgroup
  27. is, you probably don't have access to it.  Ask your systems administrator(s)
  28. for details.  (This means you can't post questions to the digest.)
  29.  
  30. The articles in these digests are taken directly from comp.sys.mac.programmer.
  31. They are not edited; all articles included in this digest are in their original
  32. posted form.  The only articles that are -not- included in these digests are
  33. those which didn't receive any replies (except those that give information
  34. rather than ask a question).  All replies to each article are concatenated
  35. onto the original article in the order in which they were received.  Article
  36. threads are not added to the digests until the last article added to the
  37. thread is at least one month old (this is to ensure that the thread is dead
  38. before adding it to the digests).
  39.  
  40. Send administrative mail to mkelly@cs.uoregon.edu.
  41.  
  42. -------------------------------------------------------
  43.  
  44. From: bob@iastate.edu (Robert P Kuehne)
  45. Subject: WANTED: Good/Comprehensive Mac Programming Book
  46. Organization: Iowa State University, Ames IA
  47. Date: Tue, 28 Apr 1992 20:34:45 GMT
  48.  
  49.  
  50.     Sorry if this is an FAQ, but...
  51.  
  52.     I am looking for a good book to get started on programming Mac
  53. software.   Preferrably a book with a C emphasis.  Note:  I know C, etc,
  54. but want a book that will give all the goodies on the Toolbox, IO,
  55. etc...  I looked at Waldenbooks, but nothing there caught my eye.  
  56. If you can help, drop me a note or post!
  57. Thanks.
  58.  
  59. Bob
  60. - -- 
  61.  ---- _ o ---------------------------------------------------------------------
  62. |   _ \<,_        "Oh, it's _you_, Bob!"             Robert P. Kuehne |
  63. |  (_)/ (_)           - That Commmercial             bob@iastate.edu  |
  64.  -----------------------------------------------------------------------------
  65.  
  66. +++++++++++++++++++++++++++
  67.  
  68. From: jeff@pro-beagle.cts.com (Jeff Jungblut)
  69. Date: 29 Apr 92 23:17:14 GMT
  70. Organization: Crash TimeSharing, El Cajon, CA
  71.  
  72. Try "Using the Macintosh Toolbox with C", second edition, by
  73. Huxham/Burnard/Takatsuka, published by Sybex, ISBN 0-89588-572-7.
  74. $29.95 at B. Dalton/Software Etc.
  75.  
  76. The emphasis is on making Toolbox calls using Think C.  I got halfway through
  77. the book in one weekend and learned enough to write a simple space-invaders
  78. game.
  79.  
  80. ---------------------------
  81.  
  82. From: zkessin@chaos.cs.brandeis.edu (Zachary 'Lego' Kessin)
  83. Subject: Format of ICON resource
  84. Organization: Brandeis University
  85. Date: Wed, 29 Apr 1992 01:39:52 GMT
  86.  
  87. I want to know how the bits are arranged in the ICON resource. Are
  88. they in 2 collums of 16 bits each or are they in one collum of 32
  89. bits?
  90. ie is it:
  91. 0   int   int
  92. 1   int   int
  93. ...
  94. 31  int   int
  95.  
  96. or 
  97. 0    LongInt
  98. 1    LongInt
  99. ...
  100. 31   LongInt
  101.  
  102. thanks an advance!
  103.  
  104. - --Zach
  105.    Zachary Kessin               
  106.  ZKessin@chaos.cs.brandeis.edu  / real.world: I don't think the    |
  107.  (617)736-5878                 /   news server gets that group!    |
  108.  
  109.  
  110. +++++++++++++++++++++++++++
  111.  
  112. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  113. Date: 29 Apr 92 18:21:25 GMT
  114. Organization: Kalamazoo College
  115.  
  116. zkessin@chaos.cs.brandeis.edu (Zachary 'Lego' Kessin) writes:
  117. >
  118. >I want to know how the bits are arranged in the ICON resource. Are
  119. >they in 2 collums of 16 bits each or are they in one collum of 32
  120. >bits?
  121. >
  122. >is it:
  123. >
  124. >0   int   int
  125. >...
  126. >31  int   int
  127. >
  128. >or 
  129. >
  130. >0    LongInt
  131. >...
  132. >31   LongInt
  133.  
  134. Yes.
  135.  
  136. It's either one.  It could be "char char char char" or
  137. "nybble nybble nybble nybble nybble nybble nybble nybble"
  138. or whatever you want.  It's a bit pattern.  However you
  139. choose to represent it, the first 32 bits will comprise
  140. the first line of the icon, the next 32 bits the second
  141. line, and so on.
  142. - -- 
  143.  Jamie McCarthy     Internet: k044477@kzoo.edu     AppleLink: j.mccarthy
  144.  "Son, I am able," she said, "though you scare me." "Watch," said I,
  145.  "beloved," I said, "watch me scare you though." Said she, "able am I, son."
  146.  
  147. ---------------------------
  148.  
  149. From: erh0362@tesla.njit.edu (Elliotte Rusty Harold)
  150. Subject: Numerical Programming in Think C
  151. Date: 29 Apr 92 15:26:18 GMT
  152. Organization: New Jersey Institute of Technology
  153.  
  154. > Another big problem with malloc for numerical programming is that 
  155. > many C compilers (including THINKC) won't malloc > 32K bytes of
  156. > space (that's 4K doubles - which is not enough for numerical analysis).
  157. > Typically, this fails by allocating 32K bytes and then allowing you
  158. > to overwrite memory beyond the end of the 32K bytes (which causes
  159. > bus errors if you're lucky and really strange behavior if your not).  
  160. >                                         -- Mike Webb
  161.  
  162.    Tell me about it! I'm working on a statistics program that starts off by 
  163. declaring several 32 by 32 by 9 arrays of floats. Think C stops the compile at 
  164. the first one because it's too big! I normally like to write and debug my 
  165. programs on the Mac and then move them to the Sparc for actual running, but now 
  166. I'm having to do everything on the Sparc (EMACS, Yuck!) Are there any plans to 
  167. cure this problem in Think C in any future version? In my opinion this 32K 
  168. segment limit makes Think an inappropriate developmnet environment for any 
  169. serious numerical work. Does MPW have this same limitation?
  170.  
  171. Elliotte Rusty Harold        Department of Applied Mathematics
  172. elharo@m.njit.edu        New Jersey Institute of Technology
  173. erh0362@tesla.njit.edu        Newark, NJ 07103
  174.  
  175. +++++++++++++++++++++++++++
  176.  
  177. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  178. Date: 29 Apr 92 18:31:57 GMT
  179. Organization: Kalamazoo College
  180.  
  181. erh0362@tesla.njit.edu (Elliotte Rusty Harold) writes:
  182. >[Mike Webb writes:]
  183. >> 
  184. >> Another big problem with malloc for numerical programming is that 
  185. >> many C compilers (including THINKC) won't malloc > 32K bytes of
  186. >> space
  187. >
  188. >   Tell me about it! I'm working on a statistics program that starts off by 
  189. >declaring several 32 by 32 by 9 arrays of floats. Think C stops the compile at 
  190. >the first one because it's too big!
  191. >...
  192. >In my opinion this 32K 
  193. >segment limit makes Think an inappropriate developmnet environment for any 
  194. >serious numerical work.
  195.  
  196. It would, if it existed.  (Should this be in the FAQ?)
  197.  
  198. You have two choices for getting more than 32K of data at a time.  The
  199. first is to turn on "Far DATA."  This requires ThC 5.  The second is to
  200. dynamically allocate it.
  201.  
  202. Mike Webb is wrong;  you can easily allocate more than 32K of data with
  203. malloc.  Look at the source if you don't believe me;  allocations larger
  204. than a certain size (15K) simply get passed to _NewPtr, and _NewPtr can
  205. get you many megabytes.
  206.  
  207. Mike's problem is that he's not using function prototypes.  malloc
  208. accepts a parameter of type size_t, which is typedef'd as unsigned long.
  209. Without that prototype, the code assumes it's passing an int, which has
  210. nasty and not-entirely-defined results.  Turn "prototype checking" on.
  211.  
  212. Elliotte, I think you're confusing static with dynamic allocation.
  213. Declaring an array at the global level in C is static allocation, and
  214. doesn't involve malloc.  Turning on Far DATA will assist you here.
  215. If you want to dynamically allocate it, simply declare the array as a
  216. pointer (in your case, "float (*myArray)[32][32]") and assign the
  217. results of a malloc() to it (in your case,
  218. "myArray = malloc(sizeof(float [32][32][9]))").
  219. - -- 
  220.  Jamie McCarthy     Internet: k044477@kzoo.edu     AppleLink: j.mccarthy
  221.  "Son, I am able," she said, "though you scare me." "Watch," said I,
  222.  "beloved," I said, "watch me scare you though." Said she, "able am I, son."
  223.  
  224. +++++++++++++++++++++++++++
  225.  
  226. From: siegel@world.std.com (Rich Siegel)
  227. Date: 29 Apr 92 20:13:09 GMT
  228. Organization: GCC Technologies
  229.  
  230. In article <1992Apr29.102618.1@tesla.njit.edu> erh0362@tesla.njit.edu (Elliotte Rusty Harold) writes:
  231. >
  232. >   Tell me about it! I'm working on a statistics program that starts off by 
  233. >declaring several 32 by 32 by 9 arrays of floats. Think C stops the compile at 
  234. >the first one because it's too big! I normally like to write and debug my 
  235. >programs on the Mac and then move them to the Sparc for actual running, but now 
  236. >I'm having to do everything on the Sparc (EMACS, Yuck!) Are there any plans to 
  237. >cure this problem in Think C in any future version? In my opinion this 32K 
  238. >segment limit makes Think an inappropriate developmnet environment for any 
  239. >serious numerical work. Does MPW have this same limitation?
  240. >
  241.     THINK C 5.0, which has been out for nearly a year, supports "far"
  242. models for both code and data.
  243.  
  244. R.
  245.  
  246. - -- 
  247. - -----------------------------------------------------------------------
  248. Rich Siegel                              Internet: siegel@world.std.com
  249. Software Engineer, Quickdraw Group
  250. GCC Technologies
  251.  
  252. +++++++++++++++++++++++++++
  253.  
  254. From: fry@tara.harvard.edu (David Fry)
  255. Date: 29 Apr 92 23:37:14 GMT
  256. Organization: Harvard Math Department
  257.  
  258. In article <1992Apr29.102618.1@tesla.njit.edu> erh0362@tesla.njit.edu (Elliotte Rusty Harold) writes:
  259. >> 
  260. >> Another big problem with malloc for numerical programming is that 
  261. >> many C compilers (including THINKC) won't malloc > 32K bytes of
  262. >> space (that's 4K doubles - which is not enough for numerical analysis).
  263. >> Typically, this fails by allocating 32K bytes and then allowing you
  264. >> to overwrite memory beyond the end of the 32K bytes (which causes
  265. >> bus errors if you're lucky and really strange behavior if your not).  
  266. >> 
  267. >>                                         -- Mike Webb
  268.  
  269. Why is this continually propagated in this newsgroup?  malloc lets you
  270. allocate more than 32K perfectly fine, provided you use it correctly.
  271. Be sure to include <stdlib.h> and/or cast the size parameter for
  272. malloc to (long).
  273.  
  274. >   Tell me about it! I'm working on a statistics program that starts off by 
  275. >declaring several 32 by 32 by 9 arrays of floats. Think C stops the compile at 
  276. >the first one because it's too big! I normally like to write and debug my 
  277. >programs on the Mac and then move them to the Sparc for actual running, but now 
  278. >I'm having to do everything on the Sparc (EMACS, Yuck!) Are there any plans to 
  279. >cure this problem in Think C in any future version? In my opinion this 32K 
  280. >segment limit makes Think an inappropriate developmnet environment for any 
  281. >serious numerical work. 
  282.  
  283. This is a small problem, but using dynamic arrays allocated with
  284. malloc does away with it.  I've done "serious" numerical work on the
  285. Mac for years with no problem.  My programs run unaltered on the Mac
  286. (in THINK C) and on other workstations.
  287.  
  288.  
  289. David Fry                               fry@math.harvard.EDU
  290. Department of Mathematics               fry@huma1.bitnet
  291. Harvard University                      ...!harvard!huma1!fry
  292. Cambridge, MA  02138            
  293.  
  294. +++++++++++++++++++++++++++
  295.  
  296. From: fry@tara.harvard.edu (David Fry)
  297. Date: 30 Apr 92 02:34:33 GMT
  298. Organization: Harvard Math Department
  299.  
  300. In article <1992Apr29.183157.4924@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  301. >erh0362@tesla.njit.edu (Elliotte Rusty Harold) writes:
  302. >>[Mike Webb writes:]
  303. >>> 
  304. >>> Another big problem with malloc for numerical programming is that 
  305. >>> many C compilers (including THINKC) won't malloc > 32K bytes of
  306. >>> space
  307. >>
  308. >>   Tell me about it! I'm working on a statistics program that starts off by 
  309. >>declaring several 32 by 32 by 9 arrays of floats. Think C stops the compile at 
  310. >>the first one because it's too big!
  311. >>...
  312. >>In my opinion this 32K 
  313. >>segment limit makes Think an inappropriate developmnet environment for any 
  314. >>serious numerical work.
  315. >
  316. >It would, if it existed.  (Should this be in the FAQ?)
  317. >
  318. >You have two choices for getting more than 32K of data at a time.  The
  319. >first is to turn on "Far DATA."  This requires ThC 5. 
  320.  
  321. I don't think this is right. The manual says that with Far Data,
  322. you're still limited to 32K of global data per source file.  In
  323. particular, you can't allocate an array more than 32K in size.  What
  324. it does allow you to do, is have, say, 10 *.c files, each with a 20K
  325. array.
  326.  
  327. David Fry                               fry@math.harvard.EDU
  328. Department of Mathematics               fry@huma1.bitnet
  329. Harvard University                      ...!harvard!huma1!fry
  330. Cambridge, MA  02138            
  331.  
  332. +++++++++++++++++++++++++++
  333.  
  334. From: alen@crash.cts.com (Alen Shapiro)
  335. Date: 30 Apr 92 03:59:04 GMT
  336. Organization: Crash TimeSharing, El Cajon, CA
  337.  
  338. In <1992Apr29.102618.1@tesla.njit.edu> erh0362@tesla.njit.edu (Elliotte Rusty Harold) writes:
  339.  
  340. >> 
  341. >> Another big problem with malloc for numerical programming is that 
  342. >> many C compilers (including THINKC) won't malloc > 32K bytes of
  343. >> space (that's 4K doubles - which is not enough for numerical analysis).
  344. >> Typically, this fails by allocating 32K bytes and then allowing you
  345. >> to overwrite memory beyond the end of the 32K bytes (which causes
  346. >> bus errors if you're lucky and really strange behavior if your not).  
  347. >> 
  348. >>                                         -- Mike Webb
  349.  
  350. >   Tell me about it! I'm working on a statistics program that starts off by 
  351. >declaring several 32 by 32 by 9 arrays of floats. Think C stops the compile at 
  352. >the first one because it's too big! I normally like to write and debug my 
  353. >programs on the Mac and then move them to the Sparc for actual running, but now 
  354. >I'm having to do everything on the Sparc (EMACS, Yuck!) Are there any plans to 
  355. >cure this problem in Think C in any future version? In my opinion this 32K 
  356. >segment limit makes Think an inappropriate developmnet environment for any 
  357. >serious numerical work. Does MPW have this same limitation?
  358.  
  359. Code is supplied below, tested under THINK C 5.0.2. I've used similar
  360. array methods on SPARC and PC (yuch!!!).
  361.  
  362. The code allocates a 3D array on the heap (method does scale and
  363. seems to be portable). Also you get to use [][][] style addressing. I threw
  364. in the "f4" array just to see if it would allocate, it does. I did not
  365. check to see if I could run off the end of memory...as it stands "f4"
  366. cannot use [][][] addressing cos the compiler does not know the
  367. x and y dimensions to build an access function. I know there is a caste
  368. that will condition the access but I've not tried that yet.
  369.  
  370. So, as things stand, this code should use a bit more memory than the
  371. flat access space that the compiler would generate, and is possibly
  372. slightly more efficient at run-time. Please (if you have time) try it out
  373. and let me know if it hits the spot (or not as the case may be).
  374.  
  375. - --alen
  376. alen@crash.cts.com
  377.  
  378. - ------Cut here----8<-----8=-----8<-----
  379. #include <stdio.h>
  380. #include <stdlib.h>
  381.  
  382. void *
  383. ccalloc(elems, sz)
  384.     size_t elems, sz; {
  385.     void *mptr = calloc(elems, sz);
  386.  
  387.     if(mptr == (void *)NULL) {
  388.         fprintf(stderr, "calloc failed to allocate %ld of %ld\n", elems, sz);
  389.         exit(1);
  390.     }
  391.     return(mptr);
  392. }
  393.  
  394. void ***
  395. three_d_array(x, y, z, el_size)
  396.     size_t el_size; {
  397.     int i, j;
  398.     void ***arr = (void ***)ccalloc((size_t)x, sizeof(void **));
  399.  
  400.     for(i=0 ; i < x ; i++) {
  401.         arr[i] = (void **)ccalloc((size_t)y, sizeof(void *));
  402.         for(j=0 ; j < y ; j++)
  403.             arr[i][j] = (void *)ccalloc((size_t)z, el_size);
  404.     }
  405.     return(arr);
  406. }
  407.  
  408. #define X    32
  409. #define Y    32
  410. #define Z    9
  411. main() {
  412.     double ***f1;
  413.     float ***f2;
  414.     int x, y, z;
  415.     float ***f4 = (float ***)ccalloc((size_t)X*(size_t)Y*(size_t)Z, sizeof(float));
  416.     
  417.     f1 = (double ***)three_d_array(X, Y, Z, sizeof(double));
  418.     /* another (unused) for good measure!!) */
  419.     f2 = (float ***)three_d_array(X, Y, Z, sizeof(float));
  420.     
  421.     /* check if each element is addressable...I used double to strain
  422.      * the system a bit more
  423.      */
  424.     fprintf(stdout, "sizeof(float:double) = %ld:%ld\n", sizeof(float), sizeof(double));
  425.     for(x=0 ; x < X ; x++)
  426.         for(y=0 ; y < Y ; y++)
  427.             for(z=0 ; z < Z ; z++)
  428.                 f1[x][y][z] = (double)x * (double)y * (double)z;
  429.  
  430.     for(x=0 ; x < X ; x++) {
  431.         for(y=0 ; y < Y ; y++) {
  432.             for(z=0 ; z < Z ; z++) {
  433.                 fprintf(stdout, "%f ", f1[x][y][z]);
  434.             }
  435.             fprintf(stdout, "\n");
  436.         }
  437.         fprintf(stdout, "\n\n");
  438.     }
  439. }
  440. - -------end
  441.  
  442. ---------------------------
  443.  
  444. From: Keith_Rollin@taligent.com (Keith Rollin)
  445. Subject: Hey! I wrote a book!
  446. Date: 23 Apr 92 21:34:49 GMT
  447. Organization: Taligent
  448.  
  449. Well, it should finally be out. "Macintosh Programming Secrets", Second Edition,
  450. should be in the stores in the next few days.
  451.  
  452. For those not familiar with it, MPS was originally written by Scott Knaster back
  453. in 1987. It covered many interesting and non-trivial aspects of programming the
  454. Macintosh, and included a lot of fun background and "whys and wherefores." Well,
  455. a lot has happened since 1987, and the book has been almost entirely rewritten
  456. by Scott and myself. Many of the old chapters were removed, and many new
  457. chapters were added. Another big difference is that the second edition has
  458. complete working source code for you to copy and put into your own
  459. applications/INITs/whatever. There's also a coupon in the back for getting the
  460. disk of source code.
  461.  
  462. Check out the introduction: I put the members of Usenet in the list of people to
  463. thank because of all the questions that are posted here that need answering!
  464.  
  465. If you're interested in the book, it's $29.95 from Addison-Wesley, ISBN
  466. 0-201-58134-5. I'll refund a dollar to the first person who finds the two bogus
  467. entries in the index.
  468.  
  469. (For you yahoos in DTS, get Abrams to buy everyone a copy...)
  470.  
  471. - ---
  472. Keith Rollin
  473. Phantom Programmer
  474. Taligent, Inc.
  475.  
  476. +++++++++++++++++++++++++++
  477.  
  478. From: time@ice.com (Tim Endres)
  479. Date: 24 Apr 92 15:36:44 GMT
  480. Organization: ICE Engineering, Inc.
  481.  
  482.  
  483. In article <65972@apple.Apple.COM> (Keith_Rollin@taligent.com), you write:
  484. > Check out the introduction: I put the members of Usenet in the list of people to
  485. > thank because of all the questions that are posted here that need answering!
  486. > If you're interested in the book, it's $29.95 from Addison-Wesley, ISBN
  487. > 0-201-58134-5. I'll refund a dollar to the first person who finds the two bogus
  488. > entries in the index.
  489.  
  490. And, Keith, how much are you going to pay us for putting an obnoxious
  491. commercial message in our face!! Play by the rules my friend!
  492.  
  493. tim.
  494.  
  495.  
  496. tim endres - time@ice.com  -or-  uupsi!tbomb!time
  497. ICE Engineering, Inc. - Phone (313) 449 8288 - FAX (313) 449-9208
  498. 8840 Main Street, Whitmore Lake, MI  48189
  499. USENET - a slow moving self parody... ph
  500.  
  501. +++++++++++++++++++++++++++
  502.  
  503. From: rsfinn@concerto.lcs.mit.edu (Russell S. Finn)
  504. Organization: MIT Laboratory for Computer Science
  505. Date: Fri, 24 Apr 1992 22:28:22 GMT
  506.  
  507. In article <1CE00001.1r59r9@tbomb.ice.com>, time@ice.com (Tim Endres) writes:
  508. |> In article <65972@apple.Apple.COM> (Keith_Rollin@taligent.com), you write:
  509. |> > Check out the introduction: I put the members of Usenet in the
  510. |> > list of people to thank because of all the questions that are
  511. |> > posted here that need answering!
  512. |> > 
  513. |> > If you're interested in the book, it's $29.95 from
  514. |> > Addison-Wesley, ISBN 0-201-58134-5. I'll refund a dollar to the
  515. |> > first person who finds the two bogus entries in the index.
  516. |> 
  517. |> And, Keith, how much are you going to pay us for putting an obnoxious
  518. |> commercial message in our face!! Play by the rules my friend!
  519.  
  520. Sorry, but I think Keith *is* playing by the rules here.  There's a
  521. difference between announcing availability of an item and actually
  522. soliciting purchases, and to my understanding the former is permitted
  523. while the latter is not.  I've seen plenty of examples of the former
  524. in a variety of newsgroups.
  525.  
  526. It's not as if Keith said, "It's $29.95; make the check out to Keith
  527. Rollin, and send it to this address; coupons for a free case of
  528. Mountain Dew go to the first 5,000 orders, so hurry..."  I think we'd
  529. all agree that would go beyond the pale.
  530.  
  531. I could go try to look up chapter and verse in the Gospel according to
  532. St. Gene, as posted monthly in news.announce.newusers, but I'm not up
  533. to it right now.
  534.  
  535. - -- Russell S. Finn
  536. rsfinn@lcs.mit.edu
  537.  
  538. +++++++++++++++++++++++++++
  539.  
  540. From: leue@crd.ge.com (Bill Leue)
  541. Date: 27 Apr 92 13:12:35 GMT
  542. Organization: General Electric Research & Development
  543.  
  544. Actually, I'm rather glad that Keith posted the notice of his new book.
  545. There's not so much good documentation on Mac programming that we couldn't use
  546. another one.  Come on people, lighten up!
  547.  
  548. - -Bill Leue
  549. leue@crd.ge.com
  550.  
  551. P.S. - Keith, I hope this one is better proofread than the last book I bought
  552. in the "Inside Out" series.  I can't remember the exact title -- something
  553. like "Advanced C Programming on the Mac" (?)  Anyway, there were several major
  554. howlers in the first chapter.  An example (repeated several times):
  555. "if (a = b) {...} "  Yikes!  Scott had better hire better proofreaders than
  556. this if he wants to preserve his good reputation!
  557.  
  558. +++++++++++++++++++++++++++
  559.  
  560. From: tthiel@m.cs.uiuc.edu (Terry Thiel)
  561. Date: 27 Apr 92 14:38:56 GMT
  562. Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
  563.  
  564. leue@crd.ge.com (Bill Leue) writes:
  565. >Actually, I'm rather glad that Keith posted the notice of his new book.
  566. >There's not so much good documentation on Mac programming that we couldn't use
  567. >another one.  Come on people, lighten up!
  568. I agree.  I am very much against commercial ads in newsgroups but if its an
  569. individual posting and especially the author it is very valuable information.
  570. Its nice to know we can get ahold of the author if we want to also.
  571. - -Terry
  572.  
  573. +++++++++++++++++++++++++++
  574.  
  575. From: dan.richard%express@freedom.msfc.nasa.gov (Dan Richard)
  576. Date: 27 Apr 92 15:38:23 GMT
  577. Organization: Macintosh Instructor
  578.  
  579. In article <1992Apr27.143856.25046@m.cs.uiuc.edu>, tthiel@m.cs.uiuc.edu (Terry Thiel) writes:
  580. > leue@crd.ge.com (Bill Leue) writes:
  581. > >Actually, I'm rather glad that Keith posted the notice of his new book.
  582. > >There's not so much good documentation on Mac programming that we couldn't use
  583. > >another one.  Come on people, lighten up!
  584. > I agree.  I am very much against commercial ads in newsgroups but if its an
  585. > individual posting and especially the author it is very valuable information.
  586. > Its nice to know we can get ahold of the author if we want to also.
  587. > -Terry
  588. I second.
  589. What is the name of the book?
  590. Would the AUTHOR please post the table contents and brief summary/intro
  591. as to its audience.
  592.  
  593. I would like to know about a book befor I buy it. I am always
  594. looking for a better to learn from and to teach with.
  595.  
  596. Dan C. Richard
  597. Macintosh Instructor
  598.  
  599. +++++++++++++++++++++++++++
  600.  
  601. From: keith@taligent.com (Keith Rollin)
  602. Date: 27 Apr 92 20:17:13 GMT
  603. Organization: Taligent
  604.  
  605. In article <1992Apr27.153823.25380@lambda.msfc.nasa.gov>,
  606. dan.richard%express@freedom.msfc.nasa.gov (Dan Richard) writes:
  607. > In article <1992Apr27.143856.25046@m.cs.uiuc.edu>, tthiel@m.cs.uiuc.edu (Terry
  608. Thiel) writes:
  609. > > 
  610. > > leue@crd.ge.com (Bill Leue) writes:
  611. > > >Actually, I'm rather glad that Keith posted the notice of his new book.
  612. > > >There's not so much good documentation on Mac programming that we couldn't
  613. use
  614. > > >another one.  Come on people, lighten up!
  615. > >
  616. > > I agree.  I am very much against commercial ads in newsgroups but if its an
  617. > > individual posting and especially the author it is very valuable
  618. information.
  619. > > Its nice to know we can get ahold of the author if we want to also.
  620. >
  621. > I second.
  622. > What is the name of the book?
  623. > Would the AUTHOR please post the table contents and brief summary/intro
  624. > as to its audience.
  625. > I would like to know about a book befor I buy it. I am always
  626. > looking for a better to learn from and to teach with.
  627. >
  628.  
  629. Well, I hope this doesn't tick off Tim Endres and all who feel like him, but
  630. here goes:
  631.  
  632. The book is called "Macintosh Programming Secrets, Second Edition." The first
  633. edition of the book was originally published in 1987. For 1992, we've totally
  634. rewritten the chapters and added tons of sample code. It's from Addison-Wesley,
  635. ISBN 0-201-58134-5, 536 pages (did you know that "ISBN" really _does_ stand for
  636. International Standard Book Number?).
  637.  
  638. Chapters 1 and 2 are pretty much the same as Chapters 1 and 2 of the first
  639. edition. It talks about Macintosh history, philosophy, and programming
  640. techniques. It's been revised to take into account the current state of Mac
  641. technology, including multi-tasking, Color QuickDraw, System 7.0 and 32-bit
  642. addressing.
  643.  
  644. The intermission that separates the philosophical discussions from the technical
  645. discussions has been changed. Originally, there was a cartoon that explained
  646. what happens during event processing in a Mac program. We've replaced that with
  647. the text from a couple of Apple's greatest About boxes. First, there's the About
  648. box from MultiFinder 1.0 with all the good parts put back in (the version
  649. actually released to the public had the good parts bleeped out). Second, there's
  650. the System 7.0a9 credits from the Circus Parade.
  651.  
  652. Chapter 3 presents a skeleton Macintosh application. The point here is not to
  653. teach a beginner how to program the Mac, but to present the program that was the
  654. basis for all the other programs in the book. You may want to check out the
  655. sample application for things that all applications should do (like handle
  656. disk-inserted events).
  657.  
  658. Chapter 4 is on Dialogs, and is loosely based on the original Dialog chapter of
  659. the first edition. We present three things: a modal dialog that deals with
  660. Cmd-key equivalents for dialog items, a movable modal dialog, and a dialog that
  661. displays a progress indicator.
  662.  
  663. Chapter 5 is about QuickDraw. Much of the first part of the chapter is a
  664. discussion on GrafPorts and CGrafPorts, updated from the first edition of the
  665. book. The second half of the chapter develops an idea presented in the first
  666. edition, where an offscreen buffer is used to save the contents of background
  667. windows while a dialog is popped to the foreground, and later used to update
  668. those windows when the dialog is closed.
  669.  
  670. Chapter 6 touches on mouse tracking. We show how to sketch out a selection, draw
  671. the "marching ants," and drag around the selected graphics. Also included is a
  672. snippet of code that reads in MacPaint pictures.
  673.  
  674. Chapter 7, on window management, shows how to implement a Windows menu that
  675. contains the titles of all open windows. It also presents window tiling and
  676. stacking algorithms that work across multiple monitors. As windows are
  677. manipulated (opened, closed, changed), we perform zooming animation like the
  678. Finder.
  679.  
  680. Chapter 8 shows how to use Standard File to select a file and a destination
  681. directory, and then copies the selected file to that directory. No fancy stuff,
  682. but enough people seem to have problems with the File Manager that showing such
  683. basic operations seemed warranted.
  684.  
  685. Chapter 9 is all about standalone code. We show three kinds. To get your feet
  686. wet, we show an INIT that simply beeps. We then develop it into an INIT that
  687. patches a trap and stays resident in the system heap (this INIT is the most
  688. useful INIT I've ever written! It allows me to emulate with a Cmd-key the action
  689. of clicking on a window's zoom box. I know QuickKeys users aren't impressed, but
  690. hey, I don't have QuickKeys). Next, we show how to write a WDEF for the windoid
  691. that Apple made famous in HyperCard but never actually added to the system.
  692. Finally, we present a custom LDEF that draws icons and which grays out
  693. individual items. This last sample also shows how to insert a List Manager list
  694. into a modal dialog.
  695.  
  696. Chapter 10 is a pot-pourri of samples that weren't large enough to warrant their
  697. own chapters. Included are: How to Check for Cmd-Period, How to Spin a Cursor,
  698. How to Hide the Menubar, and How to Ask for a Password Without Showing the User
  699. What's Typed.
  700.  
  701.  
  702. In the interest of the philosphy of Usenet, I should point out that many of the
  703. techniques demonstrated in the book can also be found free from other sources.
  704. Two major sources are the Usenet Macintosh Programmer's Guide (UMPG), and
  705. Apple's Macintosh Technical Notes and Sample Code. For instance, UMPG contains
  706. code that shows how to hide the menu bar, Mac Technote #263 shows how to
  707. identify a Cmd-Period key-down event, and a recent addition to DTS's snippets
  708. collection shows how to implement a password entry dialog.
  709.  
  710. - --
  711. Keith Rollin
  712. Phantom Programmer
  713. Taligent, Inc.
  714.  
  715. +++++++++++++++++++++++++++
  716.  
  717. From: keith@taligent.com (Keith Rollin)
  718. Date: 27 Apr 92 19:37:14 GMT
  719. Organization: Taligent
  720.  
  721. In article <1992Apr27.131235.9924@crd.ge.com>, leue@crd.ge.com (Bill Leue)
  722. writes:
  723. > P.S. - Keith, I hope this one is better proofread than the last book I bought
  724. > in the "Inside Out" series.  I can't remember the exact title -- something
  725. > like "Advanced C Programming on the Mac" (?)  Anyway, there were several major
  726. > howlers in the first chapter.  An example (repeated several times):
  727. > "if (a = b) {...} "  Yikes!  Scott had better hire better proofreaders than
  728. > this if he wants to preserve his good reputation!
  729.  
  730. I think that unsightly blemishes will always be a part of publishing. And I've
  731. already found every single one in M.P.S., 2nd Ed (right...). For instance, in a
  732. certain range of pages, "WindowPtr theWindow;" gets merged into
  733. "WindowPtrtheWindow;". And in one place in the included source code, a character
  734. of a variable name was dropped, creating a syntax error that's not in the
  735. original source code. Scott says we should be able to get these fixed for the
  736. second printing, so if anyone wants to contribute to the quality of the book,
  737. send me mail.
  738.  
  739. > something
  740. > like "Advanced C Programming on the Mac" (?)
  741.  
  742. If you can get me the exact name, I'll forward your comments on to Scott.
  743.  
  744. BTW: this is really weird, but even though Scott Knaster, the editor of the
  745. Macintosh Inside Out series, is co-author of the book, the this book itself is
  746. not part of the series. I don't know why...
  747.  
  748. - --
  749. Keith Rollin
  750. Phantom Programmer
  751. Taligent, Inc.
  752.  
  753.  
  754. +++++++++++++++++++++++++++
  755.  
  756. From: time@ice.com (Tim Endres)
  757. Date: 30 Apr 92 15:27:15 GMT
  758. Organization: ICE Engineering, Inc.
  759.  
  760.  
  761. In article <66173@apple.Apple.COM> (comp.sys.mac.programmer), keith@taligent.com (Keith Rollin) writes:
  762. > > I second.
  763. > > What is the name of the book?
  764. > > Would the AUTHOR please post the table contents and brief summary/intro
  765. > > as to its audience.
  766. > > 
  767. > > I would like to know about a book befor I buy it. I am always
  768. > > looking for a better to learn from and to teach with.
  769. > >
  770. > Well, I hope this doesn't tick off Tim Endres and all who feel like him, but
  771. > here goes:
  772.  
  773. This SHIT belongs in a proper newsgroup: comp.newprod
  774.  
  775. MOVE IT THERE! It is not impolite to post a pointer to the article,
  776. but I am getting REAL tired of this garbage taking up my bandwidth.
  777.  
  778.  
  779. tim endres - time@ice.com  -or-  uupsi!tbomb!time
  780. ICE Engineering, Inc. - Phone (313) 449 8288 - FAX (313) 449-9208
  781. 8840 Main Street, Whitmore Lake, MI  48189
  782. USENET - a slow moving self parody... ph
  783.  
  784. +++++++++++++++++++++++++++
  785.  
  786. From: kfischer@mesa.llnl.gov (K. Fischer)
  787. Date: 30 Apr 92 15:52:38 GMT
  788. Organization: LLNL
  789.  
  790. In article <1CE00001.2av03g@tbomb.ice.com>, time@ice.com (Tim Endres)
  791. writes:
  792. |>Path: lll-winken!ames!agate!spool.mu.edu!heifetz!tbomb!time
  793. |>From: time@ice.com (Tim Endres)
  794. |>Newsgroups: comp.sys.mac.programmer
  795. |>Subject: Re: Hey! I wrote a book!
  796. |>Message-ID: <1CE00001.2av03g@tbomb.ice.com>
  797. |>Date: 30 Apr 92 15:27:15 GMT
  798. |>Reply-To: time@ice.com (Tim Endres)
  799. |>Distribution: usa
  800. |>Organization: ICE Engineering, Inc.
  801. |>Lines: 24
  802. |>X-Mailer: uAccess - Macintosh Release: 1.7b4
  803. |>
  804. |>
  805. |>In article <66173@apple.Apple.COM> (comp.sys.mac.programmer),
  806. |>keith@taligent.com (Keith Rollin) writes:
  807. |>> > I second.
  808. |>> > What is the name of the book?
  809. |>> > Would the AUTHOR please post the table contents and brief
  810. |>summary/intro
  811. |>> > as to its audience.
  812. |>> > 
  813. |>> > I would like to know about a book befor I buy it. I am always
  814. |>> > looking for a better to learn from and to teach with.
  815. |>> >
  816. |>> 
  817. |>> Well, I hope this doesn't tick off Tim Endres and all who feel like
  818. |>him, but
  819. |>> here goes:
  820. |>
  821. |>This SHIT belongs in a proper newsgroup: comp.newprod
  822. |>
  823. |>MOVE IT THERE! It is not impolite to post a pointer to the article,
  824. |>but I am getting REAL tired of this garbage taking up my bandwidth.
  825. |>
  826. |>
  827. |>tim endres - time@ice.com  -or-  uupsi!tbomb!time
  828. |>ICE Engineering, Inc. - Phone (313) 449 8288 - FAX (313) 449-9208
  829. |>8840 Main Street, Whitmore Lake, MI  48189
  830. |>USENET - a slow moving self parody... ph
  831. |>
  832.  
  833. The only garbage I have seen here is YOUR posting tim -- get a grip
  834. and get off your high horse.  The information was requested by
  835. a reader and considering how many people post questions asking about
  836. books, I feel this was a nice service of the AUTHOR to post it.  Maybe
  837. you know everything and don't need books, but I'm a novice and
  838. appreciate all  the advice I can get.  Perhaps you should go off and
  839. form the comp.sys.mac.programmer.gods_only group for yourself
  840. and those like you.
  841.  
  842. Kathleen
  843. (who is usually a very nice and calm person except when provoked by
  844. computer gods who think they know everything )
  845. kfischer@mesa.llnl.gov
  846.  
  847. DISCLAIMER:  I speak for myself only
  848.  
  849. ---------------------------
  850.  
  851. From: poynton@vector.Sun.COM (Charles A. Poynton)
  852. Subject: Introduction To Video Colour Spaces (was Re: YUV format)
  853. Date: 28 Apr 92 05:17:10 GMT
  854. Organization: Sun Microsystems, Mt. View, Ca.
  855.  
  856. INTRODUCTION TO VIDEO COLOUR SPACES
  857.  
  858. Charles A. Poynton
  859. Sun Microsystems Computer Corp.
  860. (c) April 27, 1992
  861.  
  862. This note describes video luma (Y), and outlines six video-related colour
  863. spaces:  (Y, B-Y, R-Y), YPbPr, YCbCr, Kodak PhotoYCC[tm], YUV and YIQ.
  864. All of these spaces share the same luma (Y) signal; the other two signals
  865. are "colour differences" that differ only in scaling (and in the case of
  866. IQ, a rotation). The different scalings are appropriate for different
  867. uses.
  868.  
  869. Often the symbol YUV is used loosely to represent generic
  870. colour-difference space.  The scaling associated with YUV space is not
  871. correct for component digital video, and YCbCr should almost always be
  872. used instead.
  873.  
  874. To clear up some initial confusion, the symbol "Y" as used in video does
  875. **NOT** have the same meaning as the symbol Y defined by the CIE and used
  876. in colour science (such as in the CIE XYZ and CIE xyY colour spaces).
  877. Both are associated with brightness, but in colour science, luminance --
  878. denoted Y -- is proportional to linear-light intensity. Video originates
  879. with linear light, but applies a power function with an exponent of about
  880. 0.45 to implement "gamma-correction".  I call the video Y symbol "luma" to
  881. differentiate it from CIE "luminance".
  882.  
  883. Human vision treats brightness information very differently than colour
  884. information, and this is fundamentally the reason that both colour science
  885. and television identify a special channel to convey brightness-related
  886. information.
  887.  
  888. Video uses U and V components to represent colour differences, but these
  889. are essentially unrelated to colour science (u, v) or (u', v') or 
  890. (u*, v*). All of these pairs can loosely be described as representing
  891. "chroma" but they are numerically and functionally different.  Video YUV
  892. is neither based on nor superceded by any of the CIE colour-difference
  893. spaces.
  894.  
  895.  
  896. LUMA (Y)
  897.  
  898. Video originates with linear-light ("tristimulus") RGB primary components,
  899. conventionally contained in the range 0 (black) to +1 (white).
  900. >From the RGB triple, three gamma-corrected primary signals are computed;
  901. each is essentially the 0.45-power of the corresponding tristimulus value,
  902. similar to a square-root function.
  903.  
  904. In a practical system such as a television camera, however, in order to
  905. minimize noise in the dark regions of the picture it is necessary to limit
  906. the slope (gain) of the curve near black. It is now standard to limit gain
  907. to 4.5 below a tristimulus value of +0.018, and to stretch the remainder of
  908. the curve to place the Y-intercept at -0.099 in order to maintain function
  909. and tangent continuity at the breakpoint:
  910.  
  911.   Rgamma = (1.099 * pow(R,0.45)) - 0.099
  912.  
  913.   Ggamma = (1.099 * pow(G,0.45)) - 0.099
  914.  
  915.   Bgamma = (1.099 * pow(B,0.45)) - 0.099
  916.  
  917. Luma is then computed as a weighted sum of the gamma-corrected primaries:
  918.  
  919.   Y  =  0.299*Rgamma + 0.587*Ggamma + 0.114*Bgamma
  920.  
  921. The three coefficients in this equation correspond to the sensitivity of
  922. human vision to each of the RGB primaries standardized for video. For
  923. example, the low value of the blue coefficient is a consequence of
  924. saturated blue colours being perceived as having low brightness.
  925.  
  926. The luma coefficients are also a function of the white point (or
  927. "chromaticity of reference white"). Computer users commonly have a white
  928. point with a colour temperature in the range of 9300 K, which contains
  929. twice as much blue as the daylight reference CIE D65 used in television.
  930. This is reflected in pictures and monitors that look too blue.
  931.  
  932. Although television primaries have changed over the years since the
  933. adoption of the NTSC standard in 1953, the coefficients of the luma
  934. equation for 525 and 625 line video have remained unchanged. For
  935. HDTV, the primaries are different and the luma coefficients have been
  936. standardized with somewhat different values.
  937.  
  938.  
  939. B-Y, R-Y
  940.  
  941. The human visual system has much less acuity for spatial variation of
  942. colour than for brightness. Rather than conveying RGB, it is advantageous
  943. to convey luma in one channel, and colour information that has had luma
  944. "removed" in the two other channels. In an analog system, the two colour
  945. channels can have less bandwidth, typically one-third that of luma. In a
  946. digital system each of the two colour channels can have considerably
  947. less data rate (or data capacity) than luma.
  948.  
  949. Green dominates the luma channel: about 59% of the luma signal comprises
  950. green information. Therefore it is sensible -- and advantageous, for
  951. signal-to-noise reasons -- to base the two colour channels on blue and
  952. red.  The simplest way to "remove" luma from each of these is to subtract
  953. it to form the "difference" between a primary colour and luma. Hence, the
  954. basic video colour-difference pair is (B-Y), (R-Y) [pronounced "B
  955. minus Y, R minus Y"].
  956.  
  957. The (B-Y) signal reaches its extreme values at blue (R=0, G=0, B=1;
  958. Y=0.114; B-Y=+0.886) and at yellow (R=1, G=1, B=0; Y=0.886; B-Y=-0.886).
  959. Similarly, the extrema of (R-Y), +-0.701, occur at red and cyan.  These
  960. are inconvenient values for both digital and analog systems. The colour
  961. spaces YPbPr, YCbCr, PhotoYCC and YUV are simply scaled versions of (Y,
  962. B-Y, R-Y) that place the extrema of the colour difference channels at more
  963. convenient values.
  964.  
  965.  
  966. YPbPr
  967.  
  968. If three components are to be conveyed in three separate channels with
  969. identical unity excursions, then the Pb and Pr colour difference
  970. components are used:
  971.  
  972.   Pb = (0.5/0.886) * (Bgamma - Y)
  973.  
  974.   Pr = (0.5/0.701) * (Rgamma - Y)
  975.  
  976. These scale factors limit the excursion of EACH colour difference
  977. component to -0.5 .. +0.5 with respect to unity Y excursion: 0.886 is just
  978. unity less the luma coefficient of blue. In the analog domain Y is usually
  979. 0 mV (black) to 700 mV (white), and Pb and Pr are usually +- 350 mV.
  980.  
  981. YPbPr is part of the CCIR Rec. 709 HDTV standard, although different luma
  982. coefficients are used, and it is denoted E'Pb and E'Pr with subscript
  983. arrangement too complicated to be written here.
  984.  
  985. YPbPr is employed by component analog video equipment such as M-II and
  986. BetaCam; Pb and Pr bandwidth is half that of luma.
  987.  
  988.  
  989. YCbCr
  990.  
  991. The international standard CCIR Recommendation 601-1 specifies eight-bit
  992. digital coding for component video, with black at luma code 16 and white
  993. at luma code 235, and chroma in eight-bit two's complement form centred on
  994. 128 with a peak at code 224. This coding has a slightly smaller excursion
  995. for luma than for chroma: luma has 219 "risers" compared to 224 for Cb and
  996. Cr. The notation CbCr distinguishes this set from PbPr where the luma and
  997. chroma excursions are identical.
  998.  
  999. For Rec. 601-1 coding in eight bits per component,
  1000.  
  1001.   Y_8b  =  16 + 219 * Y
  1002.  
  1003.   Cb_8b = 128 + 112 * (0.5/0.886) * (Bgamma - Y)
  1004.  
  1005.   Cr_8b = 128 + 112 * (0.5/0.701) * (Rgamma - Y)
  1006.  
  1007. Some computer applications place black at luma code 0 and white at luma
  1008. code 255. In this case, the scaling and offsets above can be changed
  1009. accordingly, although broadcast-quality video requires the accommodation
  1010. for headroom and footroom provided in the CCIR 601-1 equations.
  1011.  
  1012. CCIR Rec. 601-1 calls for two-to-one horizontal subsampling of Cb and Cr,
  1013. to achieve 2/3 the data rate of RGB with virtually no perceptible
  1014. penalty.  This is denoted 4:2:2. A few digital video systems have utilized
  1015. horizontal subsampling by a factor of four, denoted 4:1:1. JPEG and MPEG
  1016. normally subsample Cb and Cr two-to-one horizontally and also two-to-one
  1017. vertically, to get 1/2 the data rate of RGB. No standard nomenclature has
  1018. been adopted to describe vertical subsampling. To get good results using
  1019. subsampling you should not just drop and replicate pixels, but implement
  1020. proper decimation and interpolation filters.
  1021.  
  1022. YCbCr coding is employed by D-1 component digital video equipment.
  1023.  
  1024.  
  1025. Kodak PhotoYCC [tm]
  1026.  
  1027. Kodak's PhotoYCC colour space (for PhotoCD) is similar to YCbCr, except
  1028. that Y is coded with lots of headroom and no footroom, and the scaling of
  1029. Cb and Cr is different from that of Rec. 601-1 in order to accommodate a
  1030. wider colour gamut:
  1031.  
  1032.   Y_8bit = (255/1.402) * Y
  1033.  
  1034.   C1_8bit = 156 + 111.40 * (Bgamma - Y)
  1035.  
  1036.   C2_8bit = 137 + 135.64 * (Rgamma - Y)
  1037.  
  1038. The C1 and C2 components are subsequently subsampled by factors of two
  1039. horizontally and vertically, but that subsampling should be considered a
  1040. feature of the compression process and not of the colour space.
  1041.  
  1042.  
  1043. YUV
  1044.  
  1045. In composite NTSC, PAL or S-video systems, it is necessary to scale (B-Y)
  1046. and (R-Y) so that the composite NTSC or PAL signal -- luma plus modulated
  1047. chroma -- is contained within the range -1/3 to +4/3. These limits reflect
  1048. the capability of composite signal recording or transmission channel. The
  1049. scale factors are obtained by two simultaneous equations involving both
  1050. B-Y and R-Y, because the limits of the composite excursion are reached at
  1051. combinations of B-Y and R-Y that are intermediate to primary colours. The
  1052. scale factors are as follows:
  1053.  
  1054.   U = 0.493 * (B - Y) 
  1055.  
  1056.   V = 0.877 * (R - Y) 
  1057.  
  1058. U and V components are typically modulated into a "chroma" component:
  1059.  
  1060.   C = U*cos(t) + V*sin(t)  
  1061.  
  1062. where t represents the ~3.58 MHz NTSC colour subcarrier. PAL coding is
  1063. similar, except that the V component switches Phase on Alternate Lines
  1064. (+-1), and the subcarrier is at a different frequency, about 4.43 MHz.
  1065.  
  1066. It is conventional for an NTSC luma signal in a composite environment
  1067. (NTSC or S-video) to have "7.5% setup":
  1068.  
  1069.   Y_setup = (3/40) + (37/40) * Y
  1070.  
  1071. A PAL signal has zero setup.
  1072.  
  1073. The two signals Y (or Y_setup) and C can be conveyed separately across an
  1074. S-video interface, or Y and C can be combined ("encoded") into composite
  1075. NTSC or PAL:
  1076.  
  1077.   NTSC = Y_setup + C
  1078.  
  1079.   PAL  = Y + C
  1080.  
  1081. U and V are only appropriate for composite transmission as 1-wire NTSC or
  1082. PAL, or 2-wire S-video. The UV scaling (or the IQ set, described below) is
  1083. incorrect when the signal is conveyed as three separate components.
  1084. Certain component video equipment has connectors labelled "YUV" that in
  1085. fact convey YPbPr signals.
  1086.  
  1087.  
  1088. YIQ
  1089.  
  1090. The U and V signals above must be carried with equal bandwidth, albeit
  1091. less than that of luma. However, the human visual system has less spatial
  1092. acuity for magenta-green transitions than it does for red-cyan. Thus, if
  1093. signals I and Q are formed from a 123 degree rotation of U and V
  1094. respectively [sic], the Q signal can be more severely filtered than I --
  1095. to about 600 kHz, compared to about 1.3 MHz -- without being perceptible
  1096. to a viewer at typical TV viewing distance.  YIQ is equivalent to YUV with
  1097. a 33 degree rotation -- AND AN AXIS FLIP -- in the UV plane.  The first
  1098. edition of W.K. Pratt "Digital Image Processing" -- and presumably other
  1099. authors that follow that bible -- has a matrix that erroneously omits the
  1100. axis flip; the second edition corrects the error.
  1101.  
  1102. Since an analog NTSC decoder has no way of knowing whether the encoder was
  1103. encoding YUV or YIQ -- it cannot detect whether the encoder was running at
  1104. 0 degree or 33 degree phase -- in analog usage the terms YUV and YIQ are
  1105. often used somewhat interchangeably. YIQ was important in the early days
  1106. of NTSC but most broadcasting equipment now encodes equiband U and V.
  1107.  
  1108. The D-2 composite digital DVTR (and the associated interface standard)
  1109. conveys NTSC modulated on the YIQ axes in the 525-line version and PAL
  1110. modulated on the YUV axes in the 625-line version.
  1111.  
  1112.  
  1113. REFERENCES
  1114.  
  1115. "Television Engineering Handbook", second edition (1986) by K. Blair
  1116. Benson -- published by McGraw-Hill -- has an explanation of the principles
  1117. of colourimetry as applied to video systems. R.W.G. Hunt's book "Colour
  1118. Reproduction in Business, Science and Industry" is an excellent text on
  1119. many aspects of colour -- I recommend it highly -- but it has only a page
  1120. of rather dated information about NTSC and PAL composite video, and it
  1121. predates YCbCr.
  1122.  
  1123.  
  1124. C.
  1125.  
  1126. - -----
  1127. Charles A. Poynton                      Sun Microsystems Inc.
  1128. vox 415-336-7846                        2550 Garcia Avenue, MTV21-10
  1129. fax 415-336-1816                        Mountain View, CA 94043
  1130. <poynton@sun.com>                       U.S.A.
  1131. "Canadian, eh."
  1132. - -----
  1133.  
  1134. +++++++++++++++++++++++++++
  1135.  
  1136. From: siri@otc.otca.oz (Siri Hewa)
  1137. Date: 30 Apr 92 03:32:45 GMT
  1138. Organization: R&D, OTC Sydney, Australia
  1139.  
  1140. Well done for the Charles article, and I think it was too theoraticle, I will
  1141. try to put from the video broadcasters angle.
  1142.  
  1143. In 601 Digital or 4:2:2 standard, components are Y:U:V and EBU(european
  1144. broadcast union) clock rate is 13.5MHz. So Y is 13.5 MHZ and U and V is sampled
  1145. on 6.75Mhz separately. Thats why its called 422. I have designed this in 1987
  1146. when D1 was just to be released.(this was in ADAC st.convertor).
  1147. In Pal YUV and in NTSC its YIQ, now lots of people will argue and Iam not going
  1148. into details as if you do your theoratical calculation you will agree with me.
  1149. But now YUV is a universal name for Pal and Ntsc.(Only designers know the real
  1150. truth).
  1151. In Beta(dont get confused with the home format with this one) and MII component
  1152. format it is YUV format is used and only slight Luminance and chroma differs
  1153. between the two.
  1154. One of the cockups in graphic area is it was design by the normal hardware and
  1155. software engineers. If this field is tackled by broadcast engineers you will
  1156. not get lots of diff. standards and misleading technical information.
  1157. Broadcasters now going to 444 standard and I see no reason for this as existing
  1158. Pal and Ntsc is well supported with 422 and if HDTV become universal then we
  1159. may have think again about new digital format.
  1160.  
  1161. Siri Hewa.
  1162. OTC Research 
  1163.  
  1164.  
  1165. ---------------------------
  1166.  
  1167. End of C.S.M.P. Digest
  1168. **********************
  1169.